@extends('layouts.admin')
@section('content')

<div class="result_wrap">
        <div class="result_title">
            
            @if (count($errors) > 0)
                <div class="mark">
                    <ul>
                        @if(is_object($errors))
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        @else
                            <li>{{ $errors }}</li>
                        @endif
                    </ul>
                </div>
            @endif
        </div>
    
    </div>
<form action="#" method="post">
      

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tbody>
                    <tr>
                        <th class="tc">ID</th>
                        <th>url</th>
                        <th>操作</th>
                    </tr>
                @foreach($res as $k => $v)    
                    <tr style="text-align:center;">
                        <td>{{ $v -> id }}</td>   
                        <td><img src="{{ $v -> pic }}" width="600px" height="200px" alt=""></td>
                        <td>
                        <a href="/admin/imgs/create">添加</a>
                       
                        
                        <a href="javascript:void(0)" onclick="delArt({{$v->id}})">删除</a>
                        
                        
                        </td>
                    </tr> 
                @endforeach    
                    </tbody>
                </table>
                

            </div>
        </div>
        <script>

        function delArt(id){

            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/imgs/')}}/'+id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });




        }

//        $(function(){
//            //询问框

//        });

    </script>
    </form>
@endsection